package twentytwentyone_3;

import java.util.Arrays;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-08 15:42
 * @Modified By:
 */
public class FindRelativeRanks_506 {

    public static void main(String[] args) {
        int[] score = new int[]{};
        System.out.println(Arrays.toString(findRelativeRanks(score)));
    }

    public static String[] findRelativeRanks(int[] score) {
        String[] result = new String[score.length];
        int change = Integer.MIN_VALUE;
        for (int i = 0; i < score.length; i++) {
            int maxScoreIndex = findMaxScoreIndex(score);
            score[maxScoreIndex] = change;
            if (i == 0){
                result[maxScoreIndex] = "Gold Medal";
            }else if (i == 1){
                result[maxScoreIndex] = "Silver Medal";
            }else if (i == 2){
                result[maxScoreIndex] = "Bronze Medal";
            }else {
                result[maxScoreIndex] = String.valueOf(i + 1);
            }
        }
        return result;
    }

    public static int findMaxScoreIndex(int[] score){
        int max = Integer.MIN_VALUE;
        int index = 0;
        for (int i = 0; i < score.length; i++) {
            if (score[i] > max){
                max = score[i];
                index = i;
            }
        }
        return index;
    }
}
